﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityBinder.Interface;

namespace EntityBinder.Binder
{
	public class ListObjectBinder : IBinder
	{
		private Type m_type;

		public BinderType BinderType
		{
			get
			{
				return BinderType.ARRAY_OF_CONTAINER;
			}
		}

		public ListObjectBinder(Type _type)
		{
			m_type = _type;
		}

		public object Read(object _source, string _content, Interface.IMemberAccess _memberAccess)
		{
			object newObject = Activator.CreateInstance(m_type);
			if (_memberAccess != null)
			{
				Internal.CollectionHelper.AddToList(_memberAccess, _source, newObject);
			}
			return newObject;
		}

		public string Write(object _source, Interface.IMemberAccess _memberAccess)
		{
			return "";
		}
	}

	public class ListObjectBinder<T> : ListObjectBinder
	{
		public ListObjectBinder() : base(typeof(T))
		{

		}
	}
}
